package cn.qzuie.smart.module.dorm.dal.mysql.bills;

import java.util.*;

import cn.qzuie.smart.framework.common.pojo.PageResult;
import cn.qzuie.smart.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.qzuie.smart.framework.mybatis.core.mapper.BaseMapperX;
import cn.qzuie.smart.module.dorm.dal.dataobject.bills.BillsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.qzuie.smart.module.dorm.controller.admin.bills.vo.*;

/**
 * 账单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BillsMapper extends BaseMapperX<BillsDO> {

    default PageResult<BillsDO> selectPage(BillsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BillsDO>()
                .eqIfPresent(BillsDO::getDormitoryId, reqVO.getDormitoryId())
                .eqIfPresent(BillsDO::getEnergyUsageIds, reqVO.getEnergyUsageIds())
                .betweenIfPresent(BillsDO::getBillDate, reqVO.getBillDate())
                .eqIfPresent(BillsDO::getTotalAmount, reqVO.getTotalAmount())
                .eqIfPresent(BillsDO::getBalance, reqVO.getBalance())
                .eqIfPresent(BillsDO::getFee, reqVO.getFee())
                .betweenIfPresent(BillsDO::getDueDate, reqVO.getDueDate())
                .betweenIfPresent(BillsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BillsDO::getId));
    }

}